package com.usian.config;

import org.springframework.cloud.gateway.filter.ratelimit.KeyResolver;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

@Configuration

public class KeyResolverConfig {

//    @Bean
//    public KeyResolver ipKeyResolver(){
//        return new KeyResolver() {
//            @Override
//            public Mono<String> resolve(ServerWebExchange exchange) {
//                return Mono.just(exchange.getRequest().getRemoteAddress().getHostName());
//            }
//        };
//    }


    @Bean
    public KeyResolver ipKeyResolver() {
        return exchange -> Mono.just( exchange.getRequest().getPath().toString() );
    }
}
